package cn.com.dhcc.ddi.datasource.vo.wapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import cn.com.dhcc.app.core.handler.dbhandler.WappedResultSet;
import cn.com.dhcc.app.core.util.JsonUtil;
import cn.com.dhcc.ddi.datasource.vo.DataSourceConfVo;
import cn.com.dhcc.ddi.datasource.vo.DataSourceVo;
/**
 * 
 * 数据源rowWapper
 * @Author: fxx
 * @date: 2017-5-16
 *
 */
public class DataSourceRowWapper implements RowMapper<DataSourceVo> {
	@Override
	public DataSourceVo mapRow(ResultSet rss, int rowNum) throws SQLException {
		WappedResultSet rs = new WappedResultSet(rss);
		DataSourceVo vo = new DataSourceVo();
		vo.setId(rs.getString("id"));
		vo.setNodeId(rs.getString("node_id"));
		vo.setNodeName(rs.getString("node_name"));
		vo.setName(rs.getString("name"));
		vo.setType(rs.getString("type"));
		vo.setConf(rs.getString("conf"));
		vo.setStatus(rs.getString("status"));
		vo.setMtime(rs.getTimestamp("mtime"));
		vo.setRemark(rs.getString("remark"));
		vo.setNeedAlert(rs.getString("needAlert"));
		
		vo.setDataSourceConfVo((JsonUtil.toObject(rs.getString("conf"), DataSourceConfVo.class)));
		
		return vo;
	}
}
